<template>
  <div class="app-container">
    <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="68px">
      <el-form-item label="品牌ID" prop="brandId">
        <el-input
          v-model="queryParams.brandId"
          placeholder="请输入品牌ID"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="型号ID" prop="modelId">
        <el-input
          v-model="queryParams.modelId"
          placeholder="请输入型号ID"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="设备编号" prop="dvcNo">
        <el-input
          v-model="queryParams.dvcNo"
          placeholder="请输入设备编号"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="发动机编号" prop="engNo">
        <el-input
          v-model="queryParams.engNo"
          placeholder="请输入发动机编号"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="企业名称" prop="ownerName">
        <el-input
          v-model="queryParams.ownerName"
          placeholder="请输入企业名称"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="企业联系方式" prop="ownerContact">
        <el-input
          v-model="queryParams.ownerContact"
          placeholder="请输入企业联系方式"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="环保编号" prop="code">
        <el-input
          v-model="queryParams.code"
          placeholder="请输入环保编号"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="排放标准" prop="rule">
        <el-select v-model="queryParams.rule" placeholder="请选择排放标准" clearable>
          <el-option
            v-for="dict in dict.type.emission_rule"
            :key="dict.value"
            :label="dict.label"
            :value="dict.value"
          />
        </el-select>
      </el-form-item>
      <el-form-item label="输入设备当前所在" prop="driverLocation">
        <el-input
          v-model="queryParams.driverLocation"
          placeholder="请输入输入设备当前所在"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="设备详细地址" prop="driverLocDetail">
        <el-input
          v-model="queryParams.driverLocDetail"
          placeholder="请输入设备详细地址"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="备案类型  1本地 2异地" prop="recordType">
        <el-select v-model="queryParams.recordType" placeholder="请选择备案类型  1本地 2异地" clearable>
          <el-option
            v-for="dict in dict.type.dev_record_type"
            :key="dict.value"
            :label="dict.label"
            :value="dict.value"
          />
        </el-select>
      </el-form-item>
      <el-form-item>
        <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
        <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
      </el-form-item>
    </el-form>

    <el-row :gutter="10" class="mb8">
      <el-col :span="1.5">
        <el-button
          type="primary"
          plain
          icon="el-icon-plus"
          size="mini"
          @click="handleAdd"
          v-hasPermi="['record:record:add']"
        >新增</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="success"
          plain
          icon="el-icon-edit"
          size="mini"
          :disabled="single"
          @click="handleUpdate"
          v-hasPermi="['record:record:edit']"
        >修改</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="danger"
          plain
          icon="el-icon-delete"
          size="mini"
          :disabled="multiple"
          @click="handleDelete"
          v-hasPermi="['record:record:remove']"
        >删除</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="warning"
          plain
          icon="el-icon-download"
          size="mini"
          @click="handleExport"
          v-hasPermi="['record:record:export']"
        >导出</el-button>
      </el-col>
      <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
    </el-row>

    <el-table v-loading="loading" :data="recordList" @selection-change="handleSelectionChange">
      <el-table-column type="selection" width="55" align="center" />
      <el-table-column label="备案ID" align="center" prop="id" />
      <el-table-column label="设备品牌" align="center" prop="dvcBrand" />
      <el-table-column label="其他设备类别" align="center" prop="dvcTypeName" />
      <el-table-column label="设备型号" align="center" prop="dvcModel" />
      <el-table-column label="企业名称" align="center" prop="ownerName" />
      <el-table-column label="企业联系方式" align="center" prop="ownerContact" />
      <el-table-column label="操作员" align="center" prop="driverName" />
      <el-table-column label="操作员联系方式" align="center" prop="driverContact" />
      <el-table-column label="环保编号" align="center" prop="code" />
      <el-table-column label="输入设备当前所在" align="center" prop="driverLocation" />
      <el-table-column label="设备详细地址" align="center" prop="driverLocDetail" />
      <el-table-column label="环保采集卡状态 1-绿卡 2-黄卡 3-红卡 4-蓝卡" align="center" prop="cardStatus">
        <template slot-scope="scope">
          <dict-tag :options="dict.type.hb_card_type" :value="scope.row.cardStatus"/>
        </template>
      </el-table-column>
      <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
        <template slot-scope="scope">
          <el-button
            size="mini"
            type="text"
            icon="el-icon-edit"
            @click="handleUpdate(scope.row)"
            v-hasPermi="['record:record:edit']"
          >修改</el-button>
          <el-button
            size="mini"
            type="text"
            icon="el-icon-delete"
            @click="handleDelete(scope.row)"
            v-hasPermi="['record:record:remove']"
          >删除</el-button>
        </template>
      </el-table-column>
    </el-table>

    <pagination
      v-show="total>0"
      :total="total"
      :page.sync="queryParams.pageNum"
      :limit.sync="queryParams.pageSize"
      @pagination="getList"
    />

    <!-- 添加或修改备案对话框 -->
    <el-dialog :title="title" :visible.sync="open" width="500px" append-to-body>
      <el-form ref="form" :model="form" :rules="rules" label-width="80px">
        <el-form-item label="会员ID" prop="memberId">
          <el-input v-model="form.memberId" placeholder="请输入会员ID" />
        </el-form-item>
        <el-form-item label="品牌ID" prop="brandId">
          <el-input v-model="form.brandId" placeholder="请输入品牌ID" />
        </el-form-item>
        <el-form-item label="设备品牌" prop="dvcBrand">
          <el-input v-model="form.dvcBrand" placeholder="请输入设备品牌" />
        </el-form-item>
        <el-form-item label="其他设备类别" prop="dvcTypeName">
          <el-input v-model="form.dvcTypeName" placeholder="请输入其他设备类别" />
        </el-form-item>
        <el-form-item label="设备型号" prop="dvcModel">
          <el-input v-model="form.dvcModel" placeholder="请输入设备型号" />
        </el-form-item>
        <el-form-item label="型号ID" prop="modelId">
          <el-input v-model="form.modelId" placeholder="请输入型号ID" />
        </el-form-item>
        <el-form-item label="设备编号" prop="dvcNo">
          <el-input v-model="form.dvcNo" placeholder="请输入设备编号" />
        </el-form-item>
        <el-form-item label="设备制造厂家" prop="dvcFct">
          <el-input v-model="form.dvcFct" placeholder="请输入设备制造厂家" />
        </el-form-item>
        <el-form-item label="设备出厂日期" prop="dvcDt">
          <el-input v-model="form.dvcDt" placeholder="请输入设备出厂日期" />
        </el-form-item>
        <el-form-item label="使用地" prop="usePlace">
          <el-select v-model="form.usePlace" placeholder="请选择使用地">
            <el-option
              v-for="dict in dict.type.use_place_type"
              :key="dict.value"
              :label="dict.label"
              :value="dict.value"
            ></el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="登记类型" prop="registType">
          <el-select v-model="form.registType" placeholder="请选择登记类型">
            <el-option
              v-for="dict in dict.type.regist_types"
              :key="dict.value"
              :label="dict.label"
              :value="dict.value"
            ></el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="发动机型号" prop="engModel">
          <el-input v-model="form.engModel" placeholder="请输入发动机型号" />
        </el-form-item>
        <el-form-item label="发动机编号" prop="engNo">
          <el-input v-model="form.engNo" placeholder="请输入发动机编号" />
        </el-form-item>
        <el-form-item label="发动机制造厂家" prop="engFct">
          <el-input v-model="form.engFct" placeholder="请输入发动机制造厂家" />
        </el-form-item>
        <el-form-item label="发动机出厂日期" prop="engDt">
          <el-input v-model="form.engDt" placeholder="请输入发动机出厂日期" />
        </el-form-item>
        <el-form-item label="油箱容量" prop="oliVolume">
          <el-input v-model="form.oliVolume" placeholder="请输入油箱容量" />
        </el-form-item>
        <el-form-item label="发动机型式核准号" prop="engCheck">
          <el-input v-model="form.engCheck" placeholder="请输入发动机型式核准号" />
        </el-form-item>
        <el-form-item label="额定功率" prop="power">
          <el-input v-model="form.power" placeholder="请输入额定功率" />
        </el-form-item>
        <el-form-item label="额定净功率" prop="netpower">
          <el-input v-model="form.netpower" placeholder="请输入额定净功率" />
        </el-form-item>
        <el-form-item label="燃料类型" prop="fuelType">
          <el-select v-model="form.fuelType" placeholder="请选择燃料类型">
            <el-option
              v-for="dict in dict.type.base_fuel_type"
              :key="dict.value"
              :label="dict.label"
              :value="parseInt(dict.value)"
            ></el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="企业名称" prop="ownerName">
          <el-input v-model="form.ownerName" placeholder="请输入企业名称" />
        </el-form-item>
        <el-form-item label="营业执照编号" prop="ownerIdentify">
          <el-input v-model="form.ownerIdentify" placeholder="请输入营业执照编号" />
        </el-form-item>
        <el-form-item label="企业联系方式" prop="ownerContact">
          <el-input v-model="form.ownerContact" placeholder="请输入企业联系方式" />
        </el-form-item>
        <el-form-item label="企业地址" prop="ownerAddress">
          <el-input v-model="form.ownerAddress" placeholder="请输入企业地址" />
        </el-form-item>
        <el-form-item label="所有人详细地址" prop="ownerAddressDetail">
          <el-input v-model="form.ownerAddressDetail" placeholder="请输入所有人详细地址" />
        </el-form-item>
        <el-form-item label="管理员" prop="adminName">
          <el-input v-model="form.adminName" placeholder="请输入管理员" />
        </el-form-item>
        <el-form-item label="管理员联系方式" prop="adminContact">
          <el-input v-model="form.adminContact" placeholder="请输入管理员联系方式" />
        </el-form-item>
        <el-form-item label="操作员" prop="driverName">
          <el-input v-model="form.driverName" placeholder="请输入操作员" />
        </el-form-item>
        <el-form-item label="操作证编号" prop="driverCert">
          <el-input v-model="form.driverCert" placeholder="请输入操作证编号" />
        </el-form-item>
        <el-form-item label="操作员联系方式" prop="driverContact">
          <el-input v-model="form.driverContact" placeholder="请输入操作员联系方式" />
        </el-form-item>
        <el-form-item label="办证机构" prop="certOrg">
          <el-input v-model="form.certOrg" placeholder="请输入办证机构" />
        </el-form-item>
        <el-form-item label="上传附件的地址" prop="files">
          <el-input v-model="form.files" type="textarea" placeholder="请输入内容" />
        </el-form-item>
        <el-form-item label="当前步骤" prop="step">
          <el-input v-model="form.step" placeholder="请输入当前步骤" />
        </el-form-item>
        <el-form-item label="环保编号" prop="code">
          <el-input v-model="form.code" placeholder="请输入环保编号" />
        </el-form-item>
        <el-form-item label="环保编号首字母" prop="rule">
          <el-input v-model="form.rule" placeholder="请输入环保编号首字母" />
        </el-form-item>
        <el-form-item label="二维码" prop="qrcode">
          <el-input v-model="form.qrcode" placeholder="请输入二维码" />
        </el-form-item>
        <el-form-item label="操作员身份证" prop="driverIdentify">
          <el-input v-model="form.driverIdentify" placeholder="请输入操作员身份证" />
        </el-form-item>
        <el-form-item label="目前施工区域" prop="driverRegion">
          <el-input v-model="form.driverRegion" placeholder="请输入目前施工区域" />
        </el-form-item>
        <el-form-item label="目前施工项目" prop="driverProject">
          <el-input v-model="form.driverProject" placeholder="请输入目前施工项目" />
        </el-form-item>
        <el-form-item label="输入设备当前所在" prop="driverLocation">
          <el-input v-model="form.driverLocation" placeholder="请输入输入设备当前所在" />
        </el-form-item>
        <el-form-item label="设备详细地址" prop="driverLocDetail">
          <el-input v-model="form.driverLocDetail" placeholder="请输入设备详细地址" />
        </el-form-item>
        <el-form-item label="备案类型  1本地 2异地" prop="recordType">
          <el-select v-model="form.recordType" placeholder="请选择备案类型  1本地 2异地">
            <el-option
              v-for="dict in dict.type.dev_record_type"
              :key="dict.value"
              :label="dict.label"
              :value="parseInt(dict.value)"
            ></el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="环保信息公开编号" prop="envNo">
          <el-input v-model="form.envNo" placeholder="请输入环保信息公开编号" />
        </el-form-item>
        <el-form-item label="机械环保代码" prop="envCode">
          <el-input v-model="form.envCode" placeholder="请输入机械环保代码" />
        </el-form-item>
        <el-form-item label="审核不通过关键字" prop="noPassKeys">
          <el-input v-model="form.noPassKeys" placeholder="请输入审核不通过关键字" />
        </el-form-item>
        <el-form-item label="审核不通过原因" prop="noPassReason">
          <el-input v-model="form.noPassReason" placeholder="请输入审核不通过原因" />
        </el-form-item>
        <el-form-item label="是否已生成工单信息：0，否；1是" prop="hasOrder">
          <el-input v-model="form.hasOrder" placeholder="请输入是否已生成工单信息：0，否；1是" />
        </el-form-item>
        <el-form-item label="是否已安装：0未安装；1已安装" prop="isInstalled">
          <el-input v-model="form.isInstalled" placeholder="请输入是否已安装：0未安装；1已安装" />
        </el-form-item>
        <el-form-item label="是否已登记" prop="isChecked">
          <el-input v-model="form.isChecked" placeholder="请输入是否已登记" />
        </el-form-item>
        <el-form-item label="车牌号" prop="carCode">
          <el-input v-model="form.carCode" placeholder="请输入车牌号" />
        </el-form-item>
        <el-form-item label="是否会进入主城区" prop="toCity">
          <el-input v-model="form.toCity" placeholder="请输入是否会进入主城区" />
        </el-form-item>
        <el-form-item label="设备类别 1级" prop="dvcLevelOne">
          <el-input v-model="form.dvcLevelOne" placeholder="请输入设备类别 1级" />
        </el-form-item>
        <el-form-item label="设备类型 -- 2级" prop="dvcLevelTwo">
          <el-input v-model="form.dvcLevelTwo" placeholder="请输入设备类型 -- 2级" />
        </el-form-item>
        <el-form-item label="设备子类型 --3级" prop="dvcLevelThree">
          <el-input v-model="form.dvcLevelThree" placeholder="请输入设备子类型 --3级" />
        </el-form-item>
        <el-form-item label="审核时间" prop="checkTime">
          <el-input v-model="form.checkTime" placeholder="请输入审核时间" />
        </el-form-item>
        <el-form-item label="dvc的附加属性信息，json格式存储id" prop="dvcAttrs">
          <el-input v-model="form.dvcAttrs" placeholder="请输入dvc的附加属性信息，json格式存储id" />
        </el-form-item>
        <el-form-item label="吨位" prop="tonnage">
          <el-input v-model="form.tonnage" placeholder="请输入吨位" />
        </el-form-item>
        <el-form-item label="${comment}" prop="remarks">
          <el-input v-model="form.remarks" placeholder="请输入${comment}" />
        </el-form-item>
        <el-form-item label="数据复审步骤:0待初检，1已初检，2已复检" prop="checkStep">
          <el-input v-model="form.checkStep" placeholder="请输入数据复审步骤:0待初检，1已初检，2已复检" />
        </el-form-item>
        <el-form-item label="设备当前城市ID，关联region表" prop="driverCityid">
          <el-input v-model="form.driverCityid" placeholder="请输入设备当前城市ID，关联region表" />
        </el-form-item>
        <el-form-item label="设备所有人当前城市ID，关联region表" prop="ownerCityid">
          <el-input v-model="form.ownerCityid" placeholder="请输入设备所有人当前城市ID，关联region表" />
        </el-form-item>
        <el-form-item label="已有的资料 1-机械铭牌 2-发动机铭牌 3-合格证 4-环保信息" prop="means">
          <el-input v-model="form.means" placeholder="请输入已有的资料 1-机械铭牌 2-发动机铭牌 3-合格证 4-环保信息" />
        </el-form-item>
        <el-form-item label="异地备案上传图片" prop="placeImg">
          <el-input v-model="form.placeImg" placeholder="请输入异地备案上传图片" />
        </el-form-item>
        <el-form-item label="APP版本号" prop="appVersion">
          <el-input v-model="form.appVersion" placeholder="请输入APP版本号" />
        </el-form-item>
        <el-form-item label="操作系统版本号" prop="sysVersion">
          <el-input v-model="form.sysVersion" placeholder="请输入操作系统版本号" />
        </el-form-item>
        <el-form-item label="手机型号 如华为，OPPO等" prop="sysName">
          <el-input v-model="form.sysName" placeholder="请输入手机型号 如华为，OPPO等" />
        </el-form-item>
        <el-form-item label="是否已经上传至环保局非道路数据库 1-已上传 " prop="isUpload">
          <el-input v-model="form.isUpload" placeholder="请输入是否已经上传至环保局非道路数据库 1-已上传 " />
        </el-form-item>
        <el-form-item label="纬度" prop="lat">
          <el-input v-model="form.lat" placeholder="请输入纬度" />
        </el-form-item>
        <el-form-item label="经度" prop="lng">
          <el-input v-model="form.lng" placeholder="请输入经度" />
        </el-form-item>
        <el-form-item label="上传接口次数，每次上传后+1,用于对上传失败的数据重复上传" prop="uploadNum">
          <el-input v-model="form.uploadNum" placeholder="请输入上传接口次数，每次上传后+1,用于对上传失败的数据重复上传" />
        </el-form-item>
        <el-form-item label="终端号" prop="tCode">
          <el-input v-model="form.tCode" placeholder="请输入终端号" />
        </el-form-item>
        <el-form-item label="${comment}" prop="carInfoId">
          <el-input v-model="form.carInfoId" placeholder="请输入${comment}" />
        </el-form-item>
        <el-form-item label="在线状态" prop="isOnline">
          <el-input v-model="form.isOnline" placeholder="请输入在线状态" />
        </el-form-item>
        <el-form-item label="国家平台上传失败错误信息" prop="errMsg">
          <el-input v-model="form.errMsg" placeholder="请输入国家平台上传失败错误信息" />
        </el-form-item>
        <el-form-item label="是否已上传采集卡图片 0-没有 1-已邮寄" prop="hasCard">
          <el-input v-model="form.hasCard" placeholder="请输入是否已上传采集卡图片 0-没有 1-已邮寄" />
        </el-form-item>
        <el-form-item label="是否已上传采集卡图片 0-未上传 1-待审核 2-审核失败 3-审核通过" prop="postCard">
          <el-input v-model="form.postCard" placeholder="请输入是否已上传采集卡图片 0-未上传 1-待审核 2-审核失败 3-审核通过" />
        </el-form-item>
        <el-form-item label="是否被处罚 0-否 1-是" prop="isPunish">
          <el-input v-model="form.isPunish" placeholder="请输入是否被处罚 0-否 1-是" />
        </el-form-item>
        <el-form-item label="OSS路径" prop="ossFiles">
          <el-input v-model="form.ossFiles" type="textarea" placeholder="请输入内容" />
        </el-form-item>
        <el-form-item label="是否已上传OSS" prop="isOssUpload">
          <el-input v-model="form.isOssUpload" placeholder="请输入是否已上传OSS" />
        </el-form-item>
        <el-form-item label="是否已验证工地管理验证码" prop="checkSmscode">
          <el-input v-model="form.checkSmscode" placeholder="请输入是否已验证工地管理验证码" />
        </el-form-item>
        <el-form-item label=" 6-X类系统删除 8-渣土车商混车删除 10-已弃用联系删除" prop="autoDel">
          <el-input v-model="form.autoDel" placeholder="请输入 6-X类系统删除 8-渣土车商混车删除 10-已弃用联系删除" />
        </el-form-item>
        <el-form-item label="绵阳卡规则判断2021-6-2日添加" prop="autoChange">
          <el-input v-model="form.autoChange" placeholder="请输入绵阳卡规则判断2021-6-2日添加" />
        </el-form-item>
        <el-form-item label="${comment}" prop="groupNames">
          <el-input v-model="form.groupNames" placeholder="请输入${comment}" />
        </el-form-item>
        <el-form-item label="是否安装" prop="autoCardUpload">
          <el-input v-model="form.autoCardUpload" placeholder="请输入是否安装" />
        </el-form-item>
        <el-form-item label="是否上传省平台" prop="isProvinceUpload">
          <el-input v-model="form.isProvinceUpload" placeholder="请输入是否上传省平台" />
        </el-form-item>
        <el-form-item label="再次上传省平台" prop="isProvinceReupload">
          <el-input v-model="form.isProvinceReupload" placeholder="请输入再次上传省平台" />
        </el-form-item>
        <el-form-item label="PIN码" prop="pin">
          <el-input v-model="form.pin" placeholder="请输入PIN码" />
        </el-form-item>
        <el-form-item label="${comment}" prop="secCheckTime">
          <el-date-picker clearable
            v-model="form.secCheckTime"
            type="date"
            value-format="yyyy-MM-dd"
            placeholder="请选择${comment}">
          </el-date-picker>
        </el-form-item>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="submitForm">确 定</el-button>
        <el-button @click="cancel">取 消</el-button>
      </div>
    </el-dialog>
  </div>
</template>

<script>
import { listRecord, getRecord, delRecord, addRecord, updateRecord } from "@/api/record/record";

export default {
  name: "Record",
  dicts: ['base_fuel_type', 'regist_types', 'hb_card_type', 'emission_rule', 'dev_record_type', 'use_place_type'],
  data() {
    return {
      // 遮罩层
      loading: true,
      // 选中数组
      ids: [],
      // 非单个禁用
      single: true,
      // 非多个禁用
      multiple: true,
      // 显示搜索条件
      showSearch: true,
      // 总条数
      total: 0,
      // 备案表格数据
      recordList: [],
      // 弹出层标题
      title: "",
      // 是否显示弹出层
      open: false,
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 10,
        brandId: null,
        dvcType: null,
        modelId: null,
        dvcNo: null,
        engNo: null,
        ownerName: null,
        ownerContact: null,
        code: null,
        rule: null,
        driverLocation: null,
        driverLocDetail: null,
        recordType: null,
      },
      // 表单参数
      form: {},
      // 表单校验
      rules: {
        noPassKeys: [
          { required: true, message: "审核不通过关键字不能为空", trigger: "blur" }
        ],
        hasOrder: [
          { required: true, message: "是否已生成工单信息：0，否；1是不能为空", trigger: "blur" }
        ],
        isInstalled: [
          { required: true, message: "是否已安装：0未安装；1已安装不能为空", trigger: "blur" }
        ],
        isChecked: [
          { required: true, message: "是否已登记不能为空", trigger: "blur" }
        ],
        toCity: [
          { required: true, message: "是否会进入主城区不能为空", trigger: "blur" }
        ],
        checkStep: [
          { required: true, message: "数据复审步骤:0待初检，1已初检，2已复检不能为空", trigger: "blur" }
        ],
        isOnline: [
          { required: true, message: "在线状态不能为空", trigger: "blur" }
        ],
        hasCard: [
          { required: true, message: "是否已上传采集卡图片 0-没有 1-已邮寄不能为空", trigger: "blur" }
        ],
      }
    };
  },
  created() {
    this.getList();
  },
  methods: {
    /** 查询备案列表 */
    getList() {
      this.loading = true;
      listRecord(this.queryParams).then(response => {
        this.recordList = response.rows;
        this.total = response.total;
        this.loading = false;
      });
    },
    // 取消按钮
    cancel() {
      this.open = false;
      this.reset();
    },
    // 表单重置
    reset() {
      this.form = {
        id: null,
        memberId: null,
        brandId: null,
        dvcBrand: null,
        dvcType: null,
        dvcTypeName: null,
        dvcModel: null,
        modelId: null,
        dvcNo: null,
        dvcFct: null,
        dvcDt: null,
        usePlace: null,
        registType: null,
        engModel: null,
        engNo: null,
        engFct: null,
        engDt: null,
        oliVolume: null,
        engCheck: null,
        power: null,
        netpower: null,
        fuelType: null,
        ownerName: null,
        ownerIdentify: null,
        ownerContact: null,
        ownerAddress: null,
        ownerAddressDetail: null,
        adminName: null,
        adminContact: null,
        driverName: null,
        driverCert: null,
        driverContact: null,
        certOrg: null,
        files: null,
        status: null,
        step: null,
        code: null,
        rule: null,
        qrcode: null,
        updateTime: null,
        createTime: null,
        driverIdentify: null,
        driverRegion: null,
        driverProject: null,
        driverLocation: null,
        driverLocDetail: null,
        recordType: null,
        envNo: null,
        envCode: null,
        noPassKeys: null,
        noPassReason: null,
        hasOrder: null,
        isInstalled: null,
        isChecked: null,
        carCode: null,
        toCity: null,
        dvcLevelOne: null,
        dvcLevelTwo: null,
        dvcLevelThree: null,
        checkTime: null,
        dvcAttrs: null,
        tonnage: null,
        remarks: null,
        checkStep: null,
        driverCityid: null,
        ownerCityid: null,
        means: null,
        placeImg: null,
        appVersion: null,
        sysVersion: null,
        appType: null,
        sysName: null,
        isUpload: null,
        lat: null,
        lng: null,
        uploadNum: null,
        tCode: null,
        carInfoId: null,
        isOnline: null,
        errMsg: null,
        hasCard: null,
        postCard: null,
        cardStatus: null,
        isPunish: null,
        ossFiles: null,
        isOssUpload: null,
        checkSmscode: null,
        autoDel: null,
        autoChange: null,
        groupNames: null,
        autoCardUpload: null,
        isProvinceUpload: null,
        isProvinceReupload: null,
        pin: null,
        secCheckTime: null
      };
      this.resetForm("form");
    },
    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.pageNum = 1;
      this.getList();
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.resetForm("queryForm");
      this.handleQuery();
    },
    // 多选框选中数据
    handleSelectionChange(selection) {
      this.ids = selection.map(item => item.id)
      this.single = selection.length!==1
      this.multiple = !selection.length
    },
    /** 新增按钮操作 */
    handleAdd() {
      this.reset();
      this.open = true;
      this.title = "添加备案";
    },
    /** 修改按钮操作 */
    handleUpdate(row) {
      this.reset();
      const id = row.id || this.ids
      getRecord(id).then(response => {
        this.form = response.data;
        this.open = true;
        this.title = "修改备案";
      });
    },
    /** 提交按钮 */
    submitForm() {
      this.$refs["form"].validate(valid => {
        if (valid) {
          if (this.form.id != null) {
            updateRecord(this.form).then(response => {
              this.$modal.msgSuccess("修改成功");
              this.open = false;
              this.getList();
            });
          } else {
            addRecord(this.form).then(response => {
              this.$modal.msgSuccess("新增成功");
              this.open = false;
              this.getList();
            });
          }
        }
      });
    },
    /** 删除按钮操作 */
    handleDelete(row) {
      const ids = row.id || this.ids;
      this.$modal.confirm('是否确认删除备案编号为"' + ids + '"的数据项？').then(function() {
        return delRecord(ids);
      }).then(() => {
        this.getList();
        this.$modal.msgSuccess("删除成功");
      }).catch(() => {});
    },
    /** 导出按钮操作 */
    handleExport() {
      this.download('record/record/export', {
        ...this.queryParams
      }, `record_${new Date().getTime()}.xlsx`)
    }
  }
};
</script>
